package com.ztgf.commodity.service;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.ztgf.commodity.common.config.YmlConfig;
import com.ztgf.commodity.mapper.CommodityCommitMsgMapper;
import com.ztgf.commodity.models.dto.CommodityCommitMsgDTO;
import com.ztgf.commodity.models.service.ICommodityCommitMsgService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;

@Slf4j
@DubboService
public class CommodityCommitMsgServiceImpl extends ServiceImpl<CommodityCommitMsgMapper, CommodityCommitMsgDTO> implements ICommodityCommitMsgService {

    @Resource
    private YmlConfig ymlConfig;

    @Override
    public void add(CommodityCommitMsgDTO dto) {
        try {
            CommodityCommitMsgDTO insertDto = new CommodityCommitMsgDTO();
            insertDto.setId(ymlConfig.getPkId());
            if (dto.getGoodsId() != null) {
                insertDto.setGoodsId(dto.getGoodsId());
            }
            insertDto.setShopId(dto.getShopId());
            insertDto.setCommitMsg(dto.getCommitMsg());
            this.insert(insertDto);
        } catch (Exception e) {
            log.error("添加商品提交数据错误信息:{}", e.getMessage());
            e.printStackTrace();
        }
    }
}
